NHSRplotthedots: Plotly Update

Marcos Fabietti

What are statistical process control charts for?

  • When used to visualise data, SPC charts can be used to understand variation in a process and highlight areas that would benefit from further investigation.
  • SPC techniques indicate areas of the process that could merit further investigation. However, it does not indicate that the process is right or wrong

Types of Variation

  • Common cause: If the process is stable and predicable any variation is known as ‘common cause variation’. A process is ‘in control’ if it only displays common cause variation.

  • Special cause :If the process is unstable or ‘out of control’ any variation is known as ‘special cause variation’. This means that it is not an inherent part of the process. Special cause variation highlights that something unusual has occurred within the process and is attributable to factors that were not within the original process design.

What is NHSRplotthedots

  • Provides tools for drawing SPC charts, developed by the NHS-R community.

  • This package supports the NHSE/I programme ‘Making Data Count’, and allows users to draw XmR charts, use change points and apply rules with summary indicators for when rules are breached.

  • Has Github Repo where contributions can be made: https://github.com/nhs-r-community/NHSRplotthedots

How to install

install the development version from GitHub using {remotes} package

 remotes::install_github(
  "https://github.com/nhs-r-community/NHSRplotthedots",
  build_vignettes = TRUE)

Example Code

library(NHSRplotthedots)
library(NHSRdatasets)
library(tidyverse)

sub_set <- ae_attendances %>%
  filter(org_code == "RQM", type == 1, period < as.Date("2018-04-01"))

sub_set %>%
  ptd_spc(value_field = breaches, date_field = period,
          improvement_direction = "decrease")

Example Code

Interactive plots with Plotly

It’s also possible to generate interactive plots using the {plotly} package by replacing the call to plot with ptd_create_plotly. This function takes the same arguments as plot/ptd_create_ggplot.

sub_set %>%
  ptd_spc(value_field = breaches, date_field = period,
          improvement_direction = "decrease") %>%
  ptd_create_plotly(
    y_axis_label = "4-hour wait breaches",
    main_title = "SPC of A&E waiting time breaches for RQM"
  )

Interactive plots with Plotly

Limitations

This was my first interaction with a NHS-R community repository, and it can still be improved:

  • Hover tips need improving (Underway - https://github.com/nhs-r-community/NHSRplotthedots/issues/178)

The impact of an active community

  • Interacted with the NHSRplotthedots Package.

  • Had the idea of having an interactive SPC chart.

  • Got approval from line manager to make time to improve it.

  • Connected with community via Slack channel, got encouraged to do it.

The impact of an active community

  • Made Pull request, got feedback about code, and made improvements based on it.

  • Peer-reviewed and tested code before merging.

  • This is a collaborative effort of 5 people.

  • We can make huge progress via collaboration.

Thank you!!

contact: marcos.fabietti@nuh.nhs.uk